import { CopyInfoPanelBase } from "../CopyInfoPanelBase";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { SecTimerView } from "../../common/SecTimerView";
import { Language } from "../../../../../extend/language/Language";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { EventName } from "../../../mvc/EventName";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { PageItemRenderer } from "../../common/renderers/PageItemRenderer";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { RemainTimeTool } from "../../award/RemainTimeTool";
import { DataEvent } from "../../../events/DataEvent";
import { FlyToNavbarTool } from "../../award/FlyToNavbarTool";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { GTextArea } from "../../../../../com/mui/controls/GTextArea";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
type int = number;
//class KingCopyInfoView
    
    export  class KingCopyInfoView extends CopyInfoPanelBase
    {
        constructor(arg1: string="MagicTowerInfoButtonBg")
        {
            super(arg1);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._textFormatTime1 = new GTextFormat(FontUtil.songtiName, 14, 65286);
            this._textFormatTime1.bold = true;
            this._tfLeftTime = new SecTimerView();
            this._tfLeftTime.setParse(Language.getString(42009));
            this._tfLeftTime.defaultTextFormat = this._textFormatTime1;
            this._tfLeftTime.filters = [FilterConst.glowFilter];
            ObjCreate.setObjAttri(this._tfLeftTime, 17, 60, 200, 20);
            this._killBossInfoText = ObjCreate.createTextArea("", 12, 38, 210, 100, _bodySp);
            this._killBossInfoText.textField.defaultTextFormat = GlobalStyle.setTextFormatLeading(GlobalStyle.textFormat5, 7);
            this._tfLeftTime.addEventListener(EventName.SecViewTimeChange, this.onSecViewTimeChange);
            this._passedTimeText = ObjCreate.createGTextField("", 17, 15, 220, 20, _bodySp, this._textFormatTime1);
            this._rewards = ObjCreate.createTileList(30, 130, 230, 120, _bodySp);
            this._rewards.scrollPolicy = ScrollPolicy.OFF;
            this._rewards.columnWidth = 41;
            this._rewards.rowHeight = 41;
            this._rewards.setStyle("cellRenderer", PageItemRenderer);
            return;
        }

        public updateLeftTime(arg1: int, arg2: int): void
        {
            this._useSec = arg2;
            this._tfLeftTime.setLeftTime(arg1);
            return;
        }

        public stopTime(): void
        {
            this._tfLeftTime.stop();
            return;
        }

        public setTitle(arg1: string): void
        {
            this.title = arg1;
            return;
        }

        public updataAwardInfo(arg1: Array<any>): void
        {
            this.updateBgHeight(arg1.length);
            this._rewards.dataProvider = new DataProvider(arg1);
            this._rewards.drawNow();
            return;
        }

        public set bossInfo(arg1: Array<any>)
        {
            var loc1=null;
            this._killBossInfoText.htmlText = "";
            var loc2=0;
            var loc3=arg1;
            for(loc1 of loc3) 
            {
                this._killBossInfoText.htmlText = this._killBossInfoText.htmlText + HTMLUtil.addColor(Language.getStringByParam(27907, loc1.bossName, loc1.killNum), GlobalStyle.color5);
            }
            return;
        }

        /* internal  */updateTimeLabel(): void
        {
            this._passedTimeText.htmlText = HTMLUtil.addColor(Language.getString(27902), "#FFFF00") + HTMLUtil.addColor(RemainTimeTool.getRemainTimeBySeconds(this._useSec, true), "#FE7E00");
            return;
        }

        /* internal  */rewardFlutter(arg1: DataEvent): void
        {
            var loc2=null;
            var loc3=null;
            if (this._rewards == null) 
            {
                return;
            }
            var loc1=this._rewards.dataProvider;
            var loc4=0;
            if (loc1) 
            {
                while (loc4 < loc1.length) 
                {
                    loc2 = this._rewards.itemToCellRenderer(loc1.getItemAt(loc4)) as PageItemRenderer;
                    if (loc2 && loc2.item) 
                    {
                        if (_zoomBtn.show) 
                        {
                            loc3 = this._rewards.localToGlobal(new Object /* flash.geom.Point */(loc2.x, loc2.y));
                        }
                        else 
                        {
                            loc3 = _zoomBtn.parent.localToGlobal(new Object /* flash.geom.Point */(_zoomBtn.x + loc2.width * loc4 + 10, _zoomBtn.y));
                        }
                        FlyToNavbarTool.flyToBackPack(loc2.item.bitmapdata, loc3);
                    }
                    ++loc4;
                }
            }
            Dispatcher.removeEventListener(EventName.GetMultiplicityRewardSuccess, this.rewardFlutter);
            return;
        }

        /* internal  */updateBgHeight(arg1: int): void
        {
            if (arg1 > 5 && arg1 <= 10) 
            {
                _bg.height = 220;
            }
            else if (arg1 > 10) 
            {
                _bg.height = 260;
            }
            return;
        }

        /* internal  */onSecViewTimeChange(arg1: DataEvent): void
        {
            var loc1;
            var loc2=((loc1 = this)._useSec + 1);
            loc1._useSec = loc2;
            this.updateTimeLabel();
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            showPanel();
            Dispatcher.addEventListener(EventName.GetMultiplicityRewardSuccess, this.rewardFlutter);
            return;
        }

        public clean(): void
        {
            this._tfLeftTime.stop();
            this._tfLeftTime = null;
            this._rewards.dataProvider = new DataProvider([]);
            this._rewards = null;
            return;
        }

        /* internal */ /* var */_tfLeftTime: SecTimerView;

        /* internal */ /* var */_textFormatTime1: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_textFormatTime2: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_textFormatTime3: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_killBossInfoText: GTextArea;

        /* internal */ /* var */_passedTimeText: GTextFiled;

        /* internal */ /* var */_rewards: GTileList;

        /* internal */ /* var */_useSec: int;
    }
